package com.example.androidlearning2422.ui.act
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

class LoginActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            MaterialTheme {
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {
                    NFTWelcomeScreen()
                }
            }
        }
    }
}

@Composable
fun NFTWelcomeScreen() {
    // 定义背景渐变：紫粉色到蓝紫色的垂直渐变
    val backgroundGradient = Brush.verticalGradient(
        colors = listOf(
            Color(0xFFF072E6), // 浅紫粉
            Color(0xFF9370DB)  // 蓝紫色
        )
    )

    Box(
        modifier = Modifier
            .fillMaxSize()
            .background(backgroundGradient),
        contentAlignment = Alignment.Center
    ) {
        Column(
            modifier = Modifier.fillMaxSize(),
            verticalArrangement = Arrangement.Center,
            horizontalAlignment = Alignment.CenterHorizontally
        ) {
            // 顶部圆角矩形 + 标题
            Box(
                modifier = Modifier
                    .size(120.dp)
                    .clip(RoundedCornerShape(24.dp))
                    .background(Color(0xFF7B2CBF)) // 深紫色
            )
            Spacer(modifier = Modifier.height(32.dp))
            Text(
                text = "欢迎使用NFT",
                fontSize = 32.sp,
                fontWeight = FontWeight.Bold,
                color = Color.White
            )
            Spacer(modifier = Modifier.height(120.dp))

            // 底部卡片区域
            Box(
                modifier = Modifier
                    .width(320.dp)
                    .clip(RoundedCornerShape(16.dp))
                    .background(Color.White.copy(alpha = 0.2f))
                    .padding(24.dp),
                contentAlignment = Alignment.Center
            ) {
                Column(horizontalAlignment = Alignment.CenterHorizontally) {
                    Text(
                        text = "探索和创造NFT",
                        fontSize = 24.sp,
                        fontWeight = FontWeight.SemiBold,
                        color = Color.White,
                        textAlign = TextAlign.Center
                    )
                    Spacer(modifier = Modifier.height(16.dp))
                    Text(
                        text = "在这里你可以买卖优秀艺术家的数字收藏品",
                        fontSize = 14.sp,
                        color = Color.White.copy(alpha = 0.8f),
                        textAlign = TextAlign.Center
                    )
                    Spacer(modifier = Modifier.height(24.dp))

                    // 立即进入按钮（渐变按钮）
                    val buttonGradient = Brush.horizontalGradient(
                        colors = listOf(
                            Color(0xFF7B2CBF), // 深紫
                            Color(0xFFE040FB)  // 亮紫
                        )
                    )
                    Box(
                        modifier = Modifier
                            .width(200.dp)
                            .height(56.dp)
                            .clip(RoundedCornerShape(28.dp))
                            .background(buttonGradient)
                            .clickable { /* 点击事件：进入首页等 */ },
                        contentAlignment = Alignment.Center
                    ) {
                        Text(
                            text = "立即进入",
                            fontSize = 18.sp,
                            fontWeight = FontWeight.Medium,
                            color = Color.White
                        )
                    }
                }
            }
        }
    }
}